package com.shiguiwu.springmybatis.spring.beanFactory;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;

/**
 * @description: 注册处理器
 * @author: stone
 * @date: Created by 2021/4/29 11:57
 * @version: 1.0.0
 * @pakeage: com.shiguiwu.springmybatis.spring.beanFactory
 */
@Component
public class MyBeanDefinitionRegistryPostProcessor implements BeanDefinitionRegistryPostProcessor, Ordered {
    @Override
    public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
        AbstractBeanDefinition shiguiwu = BeanDefinitionBuilder.genericBeanDefinition(String.class).
                addConstructorArgValue("shiguiwu")
                .getBeanDefinition();
        //注册
        registry.registerBeanDefinition("shiguiwu1", shiguiwu);
    }

    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {


    }

    @Override
    public int getOrder() {
        return 0;
    }
}
